﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Resources;
using System.IO;
using System.Reflection;

namespace br.ita.CTC34.GLCToAPConverter
{
    public class GLC
    {

    #region Properties Declarations
        public string initialSymbol { get; set; }
        public string emptyStringSymbol { get; set; }
        
        //ArrayList<char>
        public ArrayList endSymbols { get; set; }

        //ArrayList<char>
        public ArrayList nonEndSymbols { get; set; }

        //HashTable<char, ArrayList<string> >
        public Hashtable productions { get; set; }

        public static string EMPTY_STRING_SYMBOL = "Símbolo Da Cadeia Vazia";
        public static string INITIAL_SYMBOL = "Símbolo Inicial";
        public static string NON_TERMINAL_SYMBOLS = "Símbolos Não-Terminais";
        public static string PRODUCTIONS = "Produções";
        public static string TERMINAL_SYMBOLS = "Símbolos Terminais";
        public static string COLON = ":";
    #endregion

        public override string ToString()
        {
            string glc = "";

            glc += INITIAL_SYMBOL + COLON;
            glc += System.Environment.NewLine;
            
            glc += this.initialSymbol;
            glc += System.Environment.NewLine;

            glc += System.Environment.NewLine;
            glc += EMPTY_STRING_SYMBOL + COLON;
            glc += System.Environment.NewLine;

            glc += this.emptyStringSymbol;
            glc += System.Environment.NewLine;

            glc += System.Environment.NewLine;
            glc += TERMINAL_SYMBOLS + COLON;
            glc += System.Environment.NewLine;
            
            foreach(string c in endSymbols)
            {
                glc += c + " ";
            }
            glc += System.Environment.NewLine;

            glc += System.Environment.NewLine;
            glc += NON_TERMINAL_SYMBOLS + COLON;
            glc += System.Environment.NewLine;
            
            foreach (string c in nonEndSymbols)
            {
                glc += c + " ";
            }
            glc += System.Environment.NewLine;

            glc += System.Environment.NewLine;
            glc += PRODUCTIONS + COLON;
            glc += System.Environment.NewLine;
            
            foreach (DictionaryEntry p in productions)
            {
                foreach (String s in (ArrayList) p.Value)
                {
                    glc += p.Key + " -> " + s;
                    glc += System.Environment.NewLine;
                }
            }

            return glc;
        }
    }
}
